package com.cjm.one.order.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cjm.one.model.order.entity.OrderLog;
import com.cjm.one.order.service.OrderLogService;
import com.cjm.one.order.mapper.OrderLogMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 29289
* @description 针对表【order_log(订单操作日志记录)】的数据库操作Service实现
* @createDate 2024-09-05 16:11:25
*/
@Service
public class OrderLogServiceImpl extends ServiceImpl<OrderLogMapper, OrderLog>
    implements OrderLogService {
    @Resource
    private OrderLogMapper orderLogMapper;
    @Override
    public Boolean addOrderLog(OrderLog orderLog) {
        return orderLogMapper.insert(orderLog) > 0;
    }

    @Override
    public Page<OrderLog> listOrderLogPage(Integer current, Integer size) {
        Page<OrderLog> objectPage = new Page<>(current, size);
        Page<OrderLog> orderLogPage = orderLogMapper.selectPage(objectPage, null);
        return orderLogPage;
    }

    @Override
    public List<OrderLog> listOrderLog(Long orderId) {
        LambdaQueryWrapper<OrderLog> orderLogLambdaQueryWrapper = new LambdaQueryWrapper<>();
        orderLogLambdaQueryWrapper.eq(OrderLog::getOrderId, orderId);
        List<OrderLog> orderLogs = orderLogMapper.selectList(orderLogLambdaQueryWrapper);
        return orderLogs;
    }
}




